import { connect } from 'react-redux'
import Cmp  from '../App'
import { fetchTodo } from '../actions'

// 如果担心mapStateToProps 创建对象太频繁，可以使用reselect来计算衍生数据
// 太频繁会导致频繁更新组件
const mapStateToProps = (state, ownProps) => ({
    todos: state.todos
})

const mapDispatchToProps = (dispatch, ownProps) => ({
    fetchTodo: () => dispatch(fetchTodo('no id'))
})

const App = connect(mapStateToProps, mapDispatchToProps)(Cmp)

export default App
